{extend name="base/main" /}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="ibox float-e-margins">
    <div class="ibox-title">
      
    </div>
    <div class="ibox-content">
      <form id="f" action="{:url('indexes/Dsave')}" class="form-horizontal m-t"  >
        <div class="form-group">
          <label class="col-sm-2 control-label">分销模式</label>
          <div class="col-sm-4">
            <div class="radio i-checks" style="height: 60px;">
              <label class=""><input type="radio" value="指定分销" name="distribution model" checked><i></i> 指定分销</label>
              <label class=""><input type="radio" value="人人分销" name="distribution model"><i></i> 人人分销</label>
            </div>
          </div>
        </div>

       <div class="form-group">
          <label class="col-sm-2 control-label">一级推广人返佣比例</label>
          <div class="col-sm-4">
            <input name="primary promotion" class="form-control" type="text">

            <span class="help-block m-b-none Validform_checktip" ></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">二级推广人返佣比例</label>
          <div class="col-sm-4">
            <input name="secondary promotion" class="form-control" type="text">

            <span class="help-block m-b-none Validform_checktip" ></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">提现最低金额</label>
          <div class="col-sm-4">
            <input name="withdrawal" class="form-control" type="text">

            <span class="help-block m-b-none Validform_checktip" ></span>
          </div>
        </div>
          <div class="form-group">
              <label class="col-sm-2 control-label">推广人海报：</label>
              <div class="col-sm-4">
                  <div class="layui-upload">
                      <button type="button" class="layui-btn" id="test1">上传图片</button>
                      <div class="layui-upload-list">
                          <img class="layui-upload-img" id="demo1" width="100px" height="100px">
                          <input type="hidden" name="image" id="image">
                          <p id="demoText"></p>
                      </div>
                  </div>
              </div>
          </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">推广细则</label>
          <div class="col-sm-4">
            <textarea name="promotion details" placeholder="请输入内容" class="layui-textarea"></textarea>
          </div>
        </div>
		<div class="form-group">
          <label class="col-sm-2 control-label">推荐指引</label>
          <div class="col-sm-4">
            <textarea name="recommended guidelines" placeholder="请输入内容" class="layui-textarea"></textarea>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-4 col-sm-offset-3">
            <button class="btn btn-primary" type="submit">提交</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<script>
    var ue = UE.getEditor('editor_id',{});
    var ue2 = UE.getEditor('editor_n',{});
    layui.use(['upload', 'element', 'layer'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;

        upload.render({
            elem: '#test5'
            ,url: '{:url("Distributor/upload")}' //改成您自己的上传接口
            ,accept: 'video' //视频
            ,done: function(res){
                layer.msg('上传成功');
                $('#link').val(res.data);
                var html='<div><video style="width: 100%" src="'+res.data+'" class="video-ue" controls="controls"><source src="'+res.data+'"></source><video></div> <span style="color:white">.</span>';
                ue2.setContent(html,true);
                console.log(res)
            }
        });

        //常规使用 - 普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: '{:url("Distributor/upload")}' //改成您自己的上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });

                element.progress('demo', '0%'); //进度条复位
                layer.msg('上传中', {icon: 16, time: 0});
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }else{
                    $('#image').val(res.data);
                    return layer.msg('上传成功·');
                }
                //上传成功的一些操作
                //……
                $('#demoText').html(''); //置空上传失败的状态

            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }

            //进度条
            ,progress: function(n, index, e){
                element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
                if(n == 100){
                    layer.msg('上传完毕', {icon: 1});
                }
            }
        });
    });
</script>
  
{/block}